local jiliao = fk.CreateSkill{
  name = "plum__jiliao",
}

Fk:loadTranslationTable{
  ["plum__jiliao"] = "讥僚",
  [":plum__jiliao"] = "出牌阶段，你可以与一名武将牌正面向上的其他角色议事，若结果为：红色，你弃置其一张牌；黑色，你与其均翻面；无结果，"..
  "你转换〖伴虎〗且本回合〖讥僚〗失效。",

  ["#plum__jiliao"] = "讥僚：与一名武将牌正面向上的其他角色议事",
  ["#plum__jiliao-discard"] = "讥僚：弃置 %dest 一张牌",

  ["$plum__jiliao1"] = "此行不急，社稷事重。",
  ["$plum__jiliao2"] = "若至华里，不得不自还。",
}

local U = require "packages/utility/utility"

jiliao:addEffect("active", {
  anim_type = "control",
  card_num = 0,
  target_num = 1,
  prompt = "#plum__jiliao",
  can_use = function (self, player)
    return not player:isKongcheng() and player:getMark("plum__jiliao-turn") == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function (self, player, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= player and not to_select:isKongcheng() and to_select.faceup
  end,
  on_use = function (self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local discussion = U.Discussion(player, {player, target}, jiliao.name)
    if discussion.color == "red" then
      if not target.dead and not target:isNude() and not player.dead then
        local id = room:askToChooseCards(player, {
          min = 1,
          max = 1,
          target = target,
          flag = "he",
          skill_name = jiliao.name,
          prompt = "#plum__jiliao-discard::"..target.id
        })
        room:throwCard(id, jiliao.name, target, player)
      end
    elseif discussion.color == "black" then
      if not player.dead then
        player:turnOver()
      end
      if not target.dead then
        target:turnOver()
      end
    elseif not player.dead then
      room:invalidateSkill(player, jiliao.name, "-turn")
      room:setPlayerMark(player, "plum__jiliao-turn", 1)
      if player:hasSkill("plum__banhu", true) then
        room:setPlayerMark(player, MarkEnum.SwithSkillPreName.."plum__banhu", player:getSwitchSkillState("plum__banhu", true))
        player:addSkillUseHistory("plum__banhu", 1)
      end
    end
  end
})

return jiliao